//
//  XGL_UdidTool.swift
//  XGamesLive
//
//  Created by ios on 2024/5/13.
//

import Foundation
import Security

class XGL_UdidTool {
    
    static func getUUIDString() -> String {
        let uuidRef = CFUUIDCreate(kCFAllocatorDefault)
        let strRef = CFUUIDCreateString(kCFAllocatorDefault, uuidRef)
        let uuidString = (strRef! as String).replacingOccurrences(of: "-", with: "")
        let keychainItem = KeychainItemWrapper(identifier: "SoleUDID", accessGroup: nil)
        if let UUID = (keychainItem[(kSecAttrGeneric as String)] as? String){
            #if DEBUG
            print("old:"+UUID)
            #endif
            return UUID
        }
        keychainItem[(kSecAttrGeneric as String)] = uuidString as AnyObject
        #if DEBUG
        print("new:"+uuidString)
        #endif
        return uuidString
    }
}
